/*
 * @Author: lihaogn
 * @Date: 2021-12-17 17:53:34
 * @LastEditTime: 2021-12-18 21:01:17
 * @LastEditor: lihaogn
 * @Description: role 角色迁移文件
 *   创建迁移文件：npx sequelize migration:generate --name=init-roles
 *   运行迁移文件：npx sequelize db:migrate
 * @FilePath: \Lix-admin-server\database\migrations\20211217095334-init-roles.js
 */
"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { DATE, STRING } = Sequelize;
    await queryInterface.createTable("roles", {
      id: { type: STRING(40), primaryKey: true },
      name: {
        type: STRING(20),
        allowNull: false,
        unique: "uk_role_name",
      },
      description: {
        type: STRING(30),
      },
      createdAt: { type: DATE, field: "created_at" },
      updatedAt: { type: "TIMESTAMP", field: "updated_at" },
    });
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */

    await queryInterface.dropTable("roles");
  },
};
